//
//  ShellMineCell.m
//  ShellWallert
//
//  Created by lvzhao on 2019/5/15.
//  Copyright © 2019 吕VV. All rights reserved.
//

#import "ShellMineCell.h"
#import "ShellMineModel.h"

@interface ShellMineCell()

//图片
@property (nonatomic,strong) UIImageView *iconImageView;

//titlelabel
@property (nonatomic,strong) UILabel *titleLabel;
@property (nonatomic,strong) UILabel *detailLabel;

///tipview.
@property (nonatomic,strong) UILabel *tipNumberLabel;

@end

@implementation ShellMineCell



- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.backgroundColor = COLOR_BACKGROUND;
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.accessoryType  = UITableViewCellAccessoryNone;
        [self setupView];
    }
    return self;
}


#pragma mark - setupView
- (void)setupView{
    
    UIView *bgView = [[UIView alloc] init];
    bgView.backgroundColor = UIColorHex(0x08233F);
    [self.contentView addSubview:bgView];

    bgView.cornerRadius = 6;
    [bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView.mas_centerY);
        make.left.mas_equalTo(15);
        make.width.mas_equalTo(K_SCREENWIDTH-30);
        make.height.mas_equalTo(56);
    }];
    
    
    //icon图片
    [bgView addSubview:self.iconImageView];
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(bgView.mas_centerY);
        make.left.mas_equalTo(15);
        make.width.mas_equalTo(24);
        make.height.mas_equalTo(24);
    }];
  
    //title
    [bgView addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(bgView.mas_centerY);
        make.left.mas_equalTo(50);
        make.right.mas_equalTo(-100);
        make.height.mas_equalTo(bgView);
    }];

    //detailLabel
    [bgView addSubview:self.detailLabel];
    [self.detailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(bgView.mas_centerY);
        make.width.mas_equalTo(70);
        make.right.mas_equalTo(-20);
        make.height.mas_equalTo(bgView);
    }];
    
    [bgView addSubview:self.rightImageView];
    self.rightImageView.hidden = NO;
    [self.rightImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo (-15);
        make.size.mas_equalTo(CGSizeMake(self.rightImageView.image.size.width, self.rightImageView.image.size.height));
        make.centerY.mas_equalTo(self.mas_centerY);
    }];
}


#pragma mark - actions

#pragma mark - custool

#pragma mark - get && set
- (void)setModelObject:(id)modelObject{
    ShellMineModel *mineModel = modelObject;
    self.titleLabel.text = mineModel.title;
    self.detailLabel.text = mineModel.detail;
    if(mineModel.detail.length == 0){
        self.rightImageView.hidden = NO;
    } else {
        self.rightImageView.hidden = YES;
    }
    self.iconImageView.image = [UIImage imageNamed:mineModel.imageName];
}
- (UIImageView *)iconImageView{
    if (!_iconImageView) {
        _iconImageView = [[UIImageView alloc] init];
    }
    return _iconImageView;
}

//title
- (UILabel *)titleLabel{
    if(!_titleLabel){
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = UIColorHex(0xFFFFFF);
        _titleLabel.font = k_textFont(14);
        _titleLabel.numberOfLines = 2;
    }
    return _titleLabel;
}

//title
- (UILabel *)detailLabel{
    if(!_detailLabel){
        _detailLabel = [[UILabel alloc] init];
        _detailLabel.textColor = UIColorHex(0x8D99B2);
        _detailLabel.font = k_textFont(14);
        [_detailLabel lz_rightAlignment];
        _detailLabel.numberOfLines = 2;
    }
    return _detailLabel;
}


@end
